home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-12-05 | 1.0 KB | 53 lines | [TEXT/MPS ] |
- c
- c This example accepts either a string or a character argument
- c and returns the argument as a string.
- c
- c Example provided for owners of Language Systems FORTRAN
- c © 1990 Language Systems Corp.
- c
- c Written by Steven Hopkins
- c
- string function String(Str_Char_Arg)
-
- implicit none
-
- C receive the argument by Descriptor
-
- structure /DescRec/
- pointer /character*1/ DataPtr
- integer*2 DataSize
- integer*2 SymT
- end structure
- record /DescRec/ Str_Char_Arg
-
- integer*2 chard,strngd
- parameter (chard=18,strngd=19)
- pointer /character*1/ CharPtr
- integer*4 size
-
- C point to the characters so we can look
- C at them without changing the descriptor
-
- CharPtr = Str_Char_Arg.DataPtr
-
- C decide if the argument is a character
- C or a string
-
- if (Str_Char_Arg.SymT == strngd) then
- size = ichar(Str_Char_Arg.DataPtr^)
- CharPtr = CharPtr + 1
- else
- size =Str_Char_Arg.DataSize
- end if
-
- C make sure that argument will fit into a string
-
- size = MIN(255,size)
-
- C return characters as a string
- C (turn range checking off)
- !!R-
- String = CharPtr^(1:size)
-
- end
-